package tech.aistar.day12;

import java.io.*;

/**
 * 本类用来演示: 字符流 - 字符文件
 *
 * @author: success
 * @date: 2022/8/3 10:37 上午
 */
public class CopyDemo {
    public static void main(String[] args) {
        copy("src/tech/aistar/day12/FileDemo.java","src/tech/aistar/day12/FileDemo2.java");
    }

    public static void copy(String src,String target){
        try(BufferedReader in = new BufferedReader(new FileReader(src));
            PrintWriter out = new PrintWriter(new FileWriter(target),true)){

            //String readLine();//一行一行进行读取
            String content = null;

            //循环读取
            while(true){
                content = in.readLine();

                if(content==null)
                    break;

                out.println(content);
            }

            System.out.println("拷贝成功!");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
